package com.example.lxrbf;

import java.util.Iterator;

public class Card {
	public String name;
	public String[] phones;
	
	public Card(String name, String[] phones) {
		if(name != null) {
			this.name = name;
		}else this.name = "";
		if(phones != null) {
			this.phones = phones;
		}else this.phones = new String[8];
	}
	public boolean isequal(Card card) {
		return checktwo(this, card) && checktwo(card, this);
	}
	private boolean checktwo(Card card1, Card card2) {
		if(!card2.name.equals(card1.name))
			return false;
		for (String phone : card1.phones) {
			if(!isHave(card2.phones, phone))
				return false;
		}
		return true;
	}
	
	private boolean isHave(String[] ss, String s) {
		if(ss == null || s == null)
			return true;
		for (String str : ss) {
			if(s.equals(str))
				return true;
		}
		return false;
	}
}
